/**
 * 
 */
package com.swg.cocobox;

import java.io.Serializable;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.EventListener;
import java.util.EventObject;
import java.util.List;

/**
 * @author satriaprayoga
 *
 */
public abstract class EventSupport<T extends EventObject,E extends EventListener> implements Serializable {
	private static final long serialVersionUID = -1357435911441282112L;
	
	private Object source;
	
	private List<E> listeners;
	
	public EventSupport(Object source) {
		this.source=source;
		this.listeners=new ArrayList<E>();
	}
	
	public abstract T fireEvent(SocketChannel channel);
	
	public Object getSource() {
		return source;
	}
	
	public void addListener(E listener){
		listeners.add(listener);
	}
	
	public void removeListener(E listener){
		listeners.remove(listener);
	}
	
	public List<E> getListeners() {
		return listeners;
	}
	

}
